home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Question!@#!
- Date: Mon, 15 Jan 96 17:30:04 GMT
- Organization: none
- Distribution: world
- Message-ID: <821727004snz@genesis.demon.co.uk>
- References: <4dcejq$2un@venus.senecac.on.ca> <15JAN199607533289@erich.triumf.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <15JAN199607533289@erich.triumf.ca>
- bennett@erich.triumf.ca "P.Bennett" writes:
-
- >In article <4dcejq$2un@venus.senecac.on.ca>, cweselak@learn.senecac.on.ca
- > (Christian Weselak) writes...
- >>
- >>I have a very Simple question.. well, it should be simple for 'alot' of
- >>you reading this newsgroup..
- >>
- >>anyways.
- >>
- >>I have created a program that asks THE users for his name, then writes it
- >>to a file, the file is called name.txt..
-
- Post code. We can make an educated guess as to what you're doing (and
- hence what you are doing wrong). If you post code we can see what you are
- really doing wrong and don't waste time and space with possibly false
- conjecture.
-
- ...
-
- >>How can i keep this file, name.txt, so that i can eventually have a
- >>listing of all users who ran my program???
- >
- >You have to open the file in "update" mode:
- >
- > file = fopen("name.txt","a+");
-
- "r+", "w+", and "a+" are all 'update' modes which means the file can be both
- read from and written to through the open stream. If reading is not necessary
- then simply "a" will do the job. The important thing is to seek to the
- end of the file before writing. The 'append' modes "a" and "a+" do this
- automatically, but you could do this manually using fseek() (e.g. if
- the file had been opened in "r+" mode). That might be useful if it is
- sometimes necessary to modify data within the file.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-